package com.wc.算法基础课.D第四讲数学知识.欧拉函数.筛法求欧拉函数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/22 10:12
 * @description https://www.acwing.com/problem/content/876/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = (int) 1e6 + 10;
    static boolean[] isNotPrimes = new boolean[N];
    static int[] primes = new int[N / 2];
    static int idx = 0;
    static int n, x;
    static int M = 1600;
    static int[] primesA = new int[M];
    static int primesLen;

    static void ola(int x) {
        isNotPrimes[0] = isNotPrimes[1] = true;
        for (int i = 2; i <= x; i++) {
            if (!isNotPrimes[i]) primes[++idx] = i;
            for (int j = 1; i * primes[j] <= x; j++) {
                isNotPrimes[i * primes[j]] = true;
                if (i % primes[j] == 0) break;
            }
        }
    }

    public static void main(String[] args) {
        n = sc.nextInt();
        ola(n);
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            x = i;
            primesLen = 0;
            long cal = x;
            for (int j = 1; primes[j] <= x / primes[j]; j++) {
                if (x % primes[j] == 0) {
                    primesLen++;
                    primesA[primesLen] = primes[j];
                    while (x % primes[j] == 0) {
                        x /= primes[j];
                    }
                }
            }
            if (x > 1) {
                primesA[++primesLen] = x;
            }
            for (int j = 1; j <= primesLen; j++) {
                cal = cal / primesA[j] * (primesA[j] - 1);
            }
            ans += cal;
        }

        out.println(ans);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
